/*
 * @Author: your name
 * @Date: 2021-11-11 10:57:05
 * @LastEditTime: 2021-11-11 16:05:20
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /a1902-apractical2/vite-project/src/store/reducer.js
 */

import {HTTP} from './actions'

const initialState = {
    num: 0,
    name: '小明'
}

/**
 * @description: reducer的方法
 * @param {state} 初始化的状态
 * @param {actions} 调用reducer的时候传递的 actins参数
 * @return {*}
 */
export default (state = initialState, { type, payload }) => {
    switch (type) {
    case 'ADD':
        return {...state, num: state.num + 1}
    case HTTP:
        console.log(payload);
        return {...state}
    default:
        return state
    }
}
